home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / ARRAYS2.MOD < prev    next >
Text File  |  1989-01-18  |  2KB  |  69 lines

  1.                                          (* Chapter 6 - Program 2 *)
  2. MODULE Arrays2;
  3.  
  4. FROM InOut IMPORT WriteString, WriteInt, WriteLn;
  5.  
  6. VAR  Index, Count     : CARDINAL;
  7.      Checkerboard     : ARRAY[1..8] OF ARRAY[1..8] OF CARDINAL;
  8.      Value            : ARRAY[1..8],[1..8] OF CARDINAL;
  9.  
  10. BEGIN
  11.    FOR Index := 1 TO 8 DO
  12.       FOR Count := 1 TO 8 DO
  13.          Checkerboard[Index,Count] := Index + 3*Count;
  14.          Value[Index,Count] := Index + 2*Checkerboard[Index,Count];
  15.       END;  (* of Count loop *)
  16.    END;     (* of Index loop *)
  17.  
  18.    WriteString("Output of checkerboard");
  19.    WriteLn;
  20.    FOR Index := 1 TO 8 DO
  21.       FOR Count := 1 TO 8 DO
  22.          WriteInt(Checkerboard[Index,Count],6);
  23.       END;  (* of Count loop *)
  24.       WriteLn;
  25.    END;     (* of Index loop *)
  26.  
  27.    Value[3,5] := 77;   (* change a few of the values *)
  28.    Value[3,6] := 3;
  29.    Value[Value[3,6],7] := 2;  (* same as Value[3,7] := 2; *)
  30.  
  31.    WriteLn;
  32.    WriteString("Output of Value matrix");
  33.    WriteLn;
  34.    FOR Count := 1 TO 8 DO
  35.       FOR Index := 1 TO 8 DO
  36.          WriteInt(Value[Count,Index],6);
  37.       END;   (* of Index loop *)
  38.       WriteLn;
  39.    END;      (* of Count loop *)
  40. END Arrays2.
  41.  
  42.  
  43.  
  44.  
  45. (* Result of execution
  46.  
  47. Output of checkerboard
  48.      4     7    10    13    16    19    22    25
  49.      5     8    11    14    17    20    23    26
  50.      6     9    12    15    18    21    24    27
  51.      7    10    13    16    19    22    25    28
  52.      8    11    14    17    20    23    26    29
  53.      9    12    15    18    21    24    27    30
  54.     10    13    16    19    22    25    28    31
  55.     11    14    17    20    23    26    29    32
  56.  
  57. Output of Value matrix
  58.      9    15    21    27    33    39    45    51
  59.     12    18    24    30    36    42    48    54
  60.     15    21    27    33    77     3     2    57
  61.     18    24    30    36    42    48    54    60
  62.     21    27    33    39    45    51    57    63
  63.     24    30    36    42    48    54    60    66
  64.     27    33    39    45    51    57    63    69
  65.     30    36    42    48    54    60    66    72
  66.  
  67. *)
  68.  
  69.